#!/bin/bash
#Author: congyang
#Time:2019-02-08 18:49:52
#Name:c.sh
#Version: V1.0
#Description: This is a script.
. /etc/init.d/functions
urls=(
http://www.baidu.com
https://cn.bing.com
https://cn.google.com
)
cheak_count=0
function wait()
{
    echo -ne "\033[41;36m5秒后,执行检查URL\033[0m"
    for((i=0;i<5;i++))
    do
        echo -n ".";
        sleep 1
    done
    echo
}
function cheak_url()
{
    wait
    for ((i=0;i<${#urls[@]};i++))
    do
        wget -o /dev/null -T 3 --tries=1 --spider ${urls[i]} >/dev/null 2>&1
        if [ $? -eq 0 ]
        then
            action "${urls[i]}" /bin/true
            #echo  "${urls[i]}" === "OK"
        else
            action "${urls[i]}" /bin/false
            #echo  "${urls[i]}" === NOT OK
        fi
    done
    ((cheak_count++))
}
main()
{
    while true
    do
        cheak_url
        echo "---cheak count:${cheak_count}---"
        sleep 3
    done
}
main